program asfas;
var	n:integer;
	a:array[1..11] of record
		name:string[100];
		r:integer;
		end;
	i,j,b:integer;
	s:string[100];
begin
readln(n);
for j:=1 to n do begin
	readln(s);
	i:=1;
	while (i<=11) and (a[i].name <> '') do
		if s=a[i].name then
			inc(a[i].r)
		else
			inc(i);
	if (i<=11) and (a[i].r=0) then begin
		a[i].name:=s;
		a[i].r:=1;
		end;
	end;
for i:=1 to n do
	writeln(a[i].name,' ',a[i].r);
end.
